#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
    int year = 0, day = 0, month = 0;
    int i = 0;
    int sum = 0;
    scanf("%d %d %d", &year, &month, &day);
    if (year > 0 && month <= 12)
    {
        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
        {
            int a[] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
            for (i = 0; i < month - 1; i++)
            {
                sum = sum + a[i];
            }
            sum = sum + day;
        }
        else
        {
            int a[] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
            for (i = 0; i < month - 1; i++)
            {
                sum = sum + a[i];
            }
            sum = sum + day;
        }
    }
    printf("%d", sum);
    return 0;
}